

package org.argetr.resim.ui.rcp.rcp;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

/**
 * An action bar advisor is responsible for creating, adding, and disposing of
 * the actions added to a workbench window. Each window will be populated with
 * new actions.
 */
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
	private IWorkbenchAction saveAction;
	private IWorkbenchAction saveAsAction;
	private IWorkbenchAction saveAllAction;
	private IWorkbenchAction closeAction;	

	private IWorkbenchAction exitAction;

	private IAction newAction;
	private IAction openAction;
	private IAction runAction;

	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
		super(configurer);
	}

	protected void makeActions(final IWorkbenchWindow window) {
		newAction = new NewAction(window, "New Shapes", "New", true);
		openAction = new NewAction(window, "Shape Dosyas� A�", "Open File",
				false);
		
		runAction = new RunProjectAction(window,"&Run");

		saveAction = ActionFactory.SAVE.create(window);
		saveAsAction = ActionFactory.SAVE_AS.create(window);
		saveAllAction = ActionFactory.SAVE_ALL.create(window);
		closeAction  = ActionFactory.CLOSE.create(window);

		exitAction = ActionFactory.QUIT.create(window);

		register(saveAction);
		register(saveAsAction);
		register(saveAllAction);
		register(closeAction);
		register(exitAction);
		register(openAction);
		register(newAction);
		
		register(runAction);
	}

	protected void fillMenuBar(IMenuManager menuBar) {
		MenuManager fileMenu = new MenuManager("&File",
				IWorkbenchActionConstants.M_FILE);
		menuBar.add(fileMenu);
		fileMenu.add(newAction);
		fileMenu.add(openAction);

		fileMenu.add(saveAction);
		fileMenu.add(saveAsAction);
		fileMenu.add(saveAllAction);

		fileMenu.add(closeAction);		
		fileMenu.add(exitAction);
		
		MenuManager projectMenu = new MenuManager("&Project");
		projectMenu.add(runAction);
		menuBar.add(projectMenu);
	}

}
